package me.cloud.ids.jap.utils;

import cn.hutool.core.bean.BeanUtil;
import com.fujieid.jap.ids.model.ClientDetail;
import com.fujieid.jap.ids.model.UserInfo;
import lombok.experimental.UtilityClass;
import me.boot.sys.entity.SysApp;
import me.boot.sys.entity.SysUser;

/**
 * @Description:
 * @author: Sylar
 * @date: 2021年11月29日 4:31 下午
 */
@UtilityClass
public class PojoUtil {


    public ClientDetail clientFromEntity(SysApp foo) {
        if (foo == null) return null;
        ClientDetail pojo = new ClientDetail();
        BeanUtil.copyProperties(foo, pojo, true);
        pojo.setAppName(foo.getName());
        pojo.setAvailable(!foo.getInvalid());
        return pojo;
    }

    public SysApp clientToEntity(ClientDetail foo) {
        if (foo == null) return null;
        SysApp pojo = new SysApp();
        BeanUtil.copyProperties(foo, pojo, true);
        pojo.setName(foo.getAppName());
        pojo.setInvalid(!foo.getAvailable());
        return pojo;
    }

    public UserInfo userInfoFromEntity(SysUser foo) {
        if (foo == null) return null;
        UserInfo pojo = new UserInfo();
        BeanUtil.copyProperties(foo, pojo, true);
        return pojo;
    }
}
